#ifndef __CLUSTER_PROJECT_H
#define __CLUSTER_PROJECT_H
#ifndef __STD_INCLUDE
#define __STD_INCLUDE
#include <stdio.h>
#include <stdlib.h>
#endif /*#__STD_INCLUDE*/
#include "../modularity_mat/modularity_mat.h"
#include "../spectral_div/spectral_div.h"
#include "../sparse_mlpl/sparse_matrix.h"
#include "../improve_div/improve_div.h"

#define MAX_INT 32767

//int __declspec(dllexport) mainFunc(double precision);

typedef struct nodesGroup {
  int     iGroupSize;   /* size */
  int	  *Group;       /* array of row lists.  */
  int	  isDividible;  /* array of col lists.  */
  double grade;
  int numOfIter;
} nodesGroup; /* sparse matrix representation */

typedef  nodesGroup *DATA;

struct linked_list {
  DATA                d;
  struct linked_list  *next;
};

typedef  struct linked_list  ELEMENT;
typedef  ELEMENT              *LINK;

/* funution prototype */
nodesGroup *allocate_nodes_group(int n);
void freeNodesGroup(nodesGroup** G);
int createTheTrivialDivision(LINK *divisibleGroups, int iGroupSize);
int getNewDivisoin(sparse_matrix_lst *A,elem precision, nodesGroup *G,
				   nodesGroup **G1, nodesGroup **G2, elem* deltaQ);
int freeMemForGetNewDivision(elem **ModMat, elem ** GnrModMat, int *Kg,
							 elem *Fg, elem *u1, elem *S, int iGroupSize,
							 sparse_matrix_lst *Ag);
int oneAlogrithm3Itteration(sparse_matrix_lst *A, LINK *divisibleGroups, 
							LINK *undivisibleGroups, elem precision, int *numOfGroups, elem* deltaQ);


/*LInked List implemenatation is based on our exercise 2*/
int createNewList(LINK *p_list, DATA G);
int groups_compare (const void * a, const void * b);
int printList(LINK list, int iListSize, double deltaQ, char *path);
int deleteList(LINK *p_list);
int removeFromList(LINK *list, DATA G);
int insertToList(LINK *list, DATA G);
int isEmpty(LINK list);
int removeHead(LINK *list_p);

#endif /*__CLUSTER_PROJECT_H*/